﻿package mortal.game.resource
{
    import com.gengine.debug.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;

    public class ConstConfig extends Object
    {
        private var _map:Dictionary;
        private var _updateMap:Dictionary;
        private var _updateCodeKeyMap:Dictionary;
        private static var _instance:ConstConfig;

        public function ConstConfig()
        {
            this._map = new Dictionary();
            this._updateMap = new Dictionary();
            this._updateCodeKeyMap = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:Object = null;
            for each (_loc_2 in param1)
            {
                
                this._map[_loc_2.constName] = _loc_2;
            }
            return;
        }// end function

        private function writeUpdate(param1:Object) : void
        {
            var _loc_2:Object = null;
            for each (_loc_2 in param1)
            {
                
                this._updateMap[_loc_2.updateName] = _loc_2;
                this._updateCodeKeyMap[_loc_2.updateCode] = _loc_2;
            }
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_const.json");
            this.write(_loc_1);
            GameConst._somersaultDistance = this.getValueByName("somersaultDistance");
            GameConst.somersaultCd = this.getValueByName("somersaultCd");
            Cache.instance.cd.somersaultCd.totalTime = GameConst.somersaultCd * 1000;
            Cache.instance.cd.somersaultCd.totalTime = 40000;
            GameConst.PetSummonSkill = this.getValueByName("TConstPetSummonSkill");
            GameConst.PlayerMaxLevel = this.getValueByName("TConstGatePlayerMaxLevel");
            GameConst.MaxFriendAmount = this.getValueByName("MaxFriendAmount");
            GameConst.GuildSendMailInterval = this.getValueByName("GuildSendMailInterval");
            GameConst.MarketBroadcastCost = this.getValueByName("MarketBroadcastCost");
            GameConst.MarketMinFee = this.getValueByName("MarketMinFee");
            GameConst.BattleFieldCopyCode = this.getValueByName("BattleFieldCopyCode");
            GameConst.BattleFieldCampMaxPlayerNum = this.getValueByName("BattleFieldCampMaxPlayerNum");
            GameConst.GuildWarCopyCode = this.getValueByName("GuildWarCopyCode");
            GameConst.EscortEnterLevel = this.getValueByName("EscortEnterLevel");
            GameConst.DefenseCopyCode = this.getValueByName("DefenseCopyCode");
            GameConst.DefenseCopyEnterLevel = this.getValueByName("DefenseCopyEnterLevel");
            GameConst.DefenseCopyGoldStuffCode = this.getValueByName("TConstDefenseCopyGoldStuffCode");
            GameConst.TConstTeamDefenseCopyGoldStuffCode = this.getValueByName("TConstTeamDefenseCopyGoldStuffCode");
            GameConst.TConstTeamDefenseCopyDefenseTower1 = this.getValueByName("TConstTeamDefenseCopyDefenseTower1");
            GameConst.TConstTeamDefenseCopyDefenseTower2 = this.getValueByName("TConstTeamDefenseCopyDefenseTower2");
            GameConst.TConstDefenseCopyDefenseTower1 = this.getValueByName("TConstDefenseCopyDefenseTower1");
            GameConst.TConstDefenseCopyDefenseTower2 = this.getValueByName("TConstDefenseCopyDefenseTower2");
            GameConst.PetBreakMaxHp = this.getValueByName("PetBreakMaxHp");
            GameConst.PetBreakBuyHPFirstCost = this.getValueByName("PetBreakBuyHPFirstCost");
            GameConst.PetBreakBuyHPSecondCost = this.getValueByName("PetBreakBuyHPSecondCost");
            GameConst.PetBreakBuyHPThirdCost = this.getValueByName("PetBreakBuyHPThirdCost");
            GameConst.PetBreakBuyHPFourthCost = this.getValueByName("PetBreakBuyHPFourthCost");
            GameConst.PetBreakMaxSweepTimes = this.getValueByName("PetBreakMaxSweepTimes");
            GameConst.TConstLoopTaskNum = this.getValueByName("TConstLoopTaskNum");
            GameConst.TFreeCreateGuildCost = this.getValueByName("TFreeCreateGuildCost");
            GameConst.TFreeCreateGuildInviteLevel = this.getValueByName("TFreeCreateGuildInviteLevel");
            GameConst.TTodayAddActicvityMaxValue = this.getValueByName("TTodayAddActicvityMaxValue");
            GameConst.TDigGuildMemberResoureCost = this.getValueByName("TDigGuildMemberResoureCost");
            GameConst.TConstSunBathDanceRange = this.getValueByName("TConstSunBathDanceRange");
            GameConst.ArenaCopyCode1 = this.getValueByName("TConstArenaCopyCode");
            GameConst.ArenaCopyCode2 = this.getValueByName("TConstArenaCopyCode2");
            GameConst.ArenaCopyCode3 = this.getValueByName("TConstArenaCopyCode3");
            GameConst.OpenZazenLevel = this.getValueByName("TConstOpenMeditationLevel");
            GameConst.TConstPetMergeCost = this.getValueByName("TConstPetMergeCost");
            GameConst.TGuildWarehouseDonateMaxGold = this.getValueByName("TGuildWarehouseDonateMaxGold");
            GameConst.TFreeCreateGuildTaskCode = this.getValueByName("TFreeCreateGuildTaskCode");
            GameConst.TConstTowerMaxLevel = this.getValueByName("TConstTowerMaxLevel");
            GameConst.PetChangeCareerCost = this.getValueByName("PetChangeCareerCost");
            GameConst.TConstTowerCopyCode = this.getValueByName("TConstTowerCopyCode");
            GameConst.TConstTowerCopy20Level = this.getValueByName("TConstTowerCopy20Level");
            GameConst.TConstTowerMaxResetOneDay = this.getValueByName("TConstTowerMaxResetOneDay");
            GameConst.TConstTowerScanSecondsPerLevel = this.getValueByName("TConstTowerScanSecondsPerLevel");
            GameConst.TreasureHuntCopyCode = this.getValueByName("TConstRaiderCopyCode");
            GameConst.WinePartyOnlineDonateReward = this.getValueByName("TGuildWineOnlineContribution");
            GameConst.SixBossCopyCode = this.getValueByName("TConstMonsterSiegeCopyCode");
            GameConst.DrugBagMaxLife = this.getValueByName("TConstDrugBagMaxLife");
            GameConst.DrugBagMaxMana = this.getValueByName("TConstDrugBagMaxMana");
            GameConst.DrugBagMaxPetLife = this.getValueByName("TConstDrugBagMaxPetLife");
            GameConst.TConstExperWingShapeCardCode = this.getValueByName("TConstExperWingShapeCardCode");
            GameConst.TConstWingShapeCardFlyCode = this.getValueByName("TConstWingShapeCardFlyCode");
            GameConst.FightModeLevelLimit = this.getValueByName("FightModeLevelLimit");
            GameConst.TConstSprint = this.getValueByName("TConstSprint");
            GameConst.TConstSomersaultExpend = this.getValueByName("TConstSomersaultExpend");
            GameConst.TRoutineTaskBeingRefreshCount = this.getValueByName("TRoutineTaskBeingRefreshCount");
            GameConst.TRoutineTaskRefreshCount = this.getValueByName("TRoutineTaskRefreshCount");
            GameConst.TMinningTaskMaxCount = this.getValueByName("TMinningTaskMaxCount");
            GameConst.MaxAnger = this.getValueByName("XPSkillMaxAnger");
            GameConst.ExtraEscortCost = this.getValueByName("ExtraEscortCost");
            GameConst.TDay1FirstRechargeGiftCode = this.getValueByName("TDay1FirstRechargeGiftCode");
            GameConst.TDay2FirstRechargeGiftCode = this.getValueByName("TDay2FirstRechargeGiftCode");
            GameConst.TDay3FirstRechargeGiftCode = this.getValueByName("TDay3FirstRechargeGiftCode");
            GameConst.TDay4FirstRechargeGiftCode = this.getValueByName("TDay4FirstRechargeGiftCode");
            GameConst.TDay5FirstRechargeGiftCode = this.getValueByName("TDay5FirstRechargeGiftCode");
            GameConst.TDay6FirstRechargeGiftCode = this.getValueByName("TDay6FirstRechargeGiftCode");
            GameConst.TDay7FirstRechargeGiftCode = this.getValueByName("TDay7FirstRechargeGiftCode");
            GameConst.TDay8FirstRechargeGiftCode = this.getValueByName("TDay8FirstRechargeGiftCode");
            GameConst.TDay9FirstRechargeGiftCode = this.getValueByName("TDay9FirstRechargeGiftCode");
            GameConst.TDay10FirstRechargeGiftCode = this.getValueByName("TDay10FirstRechargeGiftCode");
            GameConst.TDay11FirstRechargeGiftCode = this.getValueByName("TDay11FirstRechargeGiftCode");
            GameConst.TGuildWineDrunkBuffId = this.getValueByName("TGuildWineDrunkBuffId");
            GameConst.TGuildWineLanmuBuffId = this.getValueByName("TGuildWineLanmuBuffId");
            GameConst.TGuildWinePutaoBuffId = this.getValueByName("TGuildWinePutaoBuffId");
            GameConst.TGuildWineWhiskyBuffId = this.getValueByName("TGuildWineWhiskyBuffId");
            GameConst.TGuildWinePersonAlcohol = this.getValueByName("TGuildWinePersonAlcohol");
            GameConst.TConstExpCopyItemCode = this.getValueByName("TConstExpCopyItemCode");
            GameConst.RankOpenLevel = GameDefConfig.instance.getSystemOpenLevel(12);
            GameConst.ArenaOpenLevel = GameDefConfig.instance.getSystemOpenLevel(30);
            GameConst.HeroArenaOpenLevel = GameDefConfig.instance.getSystemOpenLevel(100);
            GameConst.FriendOpenLevel = GameDefConfig.instance.getSystemOpenLevel(14);
            GameConst.SignUpOpenLevel = GameDefConfig.instance.getSystemOpenLevel(13);
            GameConst.MailOpenLevel = GameDefConfig.instance.getSystemOpenLevel(31);
            GameConst.MarketOpenLevel = GameDefConfig.instance.getSystemOpenLevel(15);
            GameConst.AchievementOpenLevel = GameDefConfig.instance.getSystemOpenLevel(57);
            GameConst.WingOpenLevel = GameDefConfig.instance.getSystemOpenLevel(67);
            GameConst.ArtifactOpenLevel = GameDefConfig.instance.getSystemOpenLevel(68);
            GameConst.ClothOpenLevel = GameDefConfig.instance.getSystemOpenLevel(66);
            GameConst.FightSoulOpenLevel = GameDefConfig.instance.getSystemOpenLevel(69);
            GameConst.FightMethodOpenLevel = GameDefConfig.instance.getSystemOpenLevel(70);
            GameConst.DragonSoulOpenLevel = GameDefConfig.instance.getSystemOpenLevel(71);
            GameConst.HolyBookOpenLevel = GameDefConfig.instance.getSystemOpenLevel(96);
            GameConst.WarShieldOpenLevel = GameDefConfig.instance.getSystemOpenLevel(97);
            GameConst.MonsterSoulOpenLevel = GameDefConfig.instance.getSystemOpenLevel(98);
            GameConst.BattleFieldMiniEnterLevel = GameDefConfig.instance.getSystemOpenLevel(39);
            GameConst.OpenZazenLevel = GameDefConfig.instance.getSystemOpenLevel(38);
            GameConst.AutoArenaOpenLevel = GameDefConfig.instance.getSystemOpenLevel(61);
            GameConst.WorldBossOpenLevel = GameDefConfig.instance.getSystemOpenLevel(80);
            GameConst.sixBossOpenLevel = GameDefConfig.instance.getSystemOpenLevel(81);
            GameConst.ChallengeCopyCode = this.getValueByName("ChallengeCopyCode");
            GameConst.GuildDefenseBlood = this.getValueByName("TGuildDefenseBlood");
            GameConst.UniqueBossEnterLevel = CopyConfig.instance.getCopyInfoByCode(GameConst.UniqueBossCopyCode).enterMinLevel;
            GameConst.TYYPurpleMonthGiftCode = this.getValueByName("TYYPurpleMonthGiftCode");
            GameConst.TYYPurpleYearGiftCode = this.getValueByName("TYYPurpleYearGiftCode");
            _loc_1 = ConfigManager.instance.getJSONByFileName("t_update_code.json");
            this.writeUpdate(_loc_1);
            UpdateCode.EUpdateCodeNULL = this.getCodeByName("EUpdateCodeNULL");
            UpdateCode.EUpdateCodeTest = this.getCodeByName("EUpdateCodeTest");
            UpdateCode.EUpdateCodeBossDrop = this.getCodeByName("EUpdateCodeBossDrop");
            UpdateCode.EUpdateCodeBossDropGroup = this.getCodeByName("EUpdateCodeBossDropGroup");
            UpdateCode.EUpdateCodeLoginPushBag = this.getCodeByName("EUpdateCodeLoginPushBag");
            UpdateCode.EUpdateCodeBagTidy = this.getCodeByName("EUpdateCodeBagTidy");
            UpdateCode.EUpdateCodeBagUseDrug = this.getCodeByName("EUpdateCodeBagUseDrug");
            UpdateCode.EUpdateCodeBagClientGet = this.getCodeByName("EUpdateCodeBagClientGet");
            UpdateCode.EUpdateCodeBagUseItem = this.getCodeByName("EUpdateCodeBagUseItem");
            UpdateCode.EUpdateCodeBagDestroyItem = this.getCodeByName("EUpdateCodeBagDestroyItem");
            UpdateCode.EUpdateCodeSellItemToSystem = this.getCodeByName("EUpdateCodeSellItemToSystem");
            UpdateCode.EUpdateCodeBagSplit = this.getCodeByName("EUpdateCodeBagSplit");
            UpdateCode.EUpdateCodeUseDrugBag = this.getCodeByName("EUpdateCodeUseDrugBag");
            UpdateCode.EUpdateCodeShopBuyItem = this.getCodeByName("EUpdateCodeShopBuyItem");
            UpdateCode.EUpdateCodeDress = this.getCodeByName("EUpdateCodeDress");
            UpdateCode.EUpdateCodeBagMove = this.getCodeByName("EUpdateCodeBagMove");
            UpdateCode.EUpdateCodeShopPanicBuy = this.getCodeByName("EUpdateCodeShopPanicBuy");
            UpdateCode.EUpdateCodeDefenseDropAdd = this.getCodeByName("EUpdateCodeDefenseDropAdd");
            UpdateCode.EUpdateCodeMount777 = this.getCodeByName("EUpdateCodeMount777");
            UpdateCode.EUpdateCodeTask = this.getCodeByName("EUpdateCodeTask");
            UpdateCode.EUpdateCodeTaskAndGuide = this.getCodeByName("EUpdateCodeTaskAndGuide");
            UpdateCode.EUpdateCodeZazen = this.getCodeByName("EUpdateCodeZazen");
            UpdateCode.EUPdateCodeCollectFashion = this.getCodeByName("EUPdateCodeCollectFashion");
            UpdateCode.EUPdateCodeFashionOutOfDate = this.getCodeByName("EUPdateCodeFashionOutOfDate");
            UpdateCode.EUpdateCodeGift = this.getCodeByName("EUpdateCodeGift");
            UpdateCode.EUpdateCodeDefenseCopy = this.getCodeByName("EUpdateCodeDefenseCopy");
            UpdateCode.EUpdateCodeGift = this.getCodeByName("EUpdateCodeGift");
            UpdateCode.EUpdateCodeLevelGift = this.getCodeByName("EUpdateCodeLevelGift");
            UpdateCode.EUpdateCodeSunBath = this.getCodeByName("EUpdateCodeSunBath");
            UpdateCode.EUpdateCodeBossDropDirToBagDir = this.getCodeByName("EUpdateCodeBossDropDirToBagDir");
            UpdateCode.EUpdateCodeMedalLoginPush = this.getCodeByName("EUpdateCodeMedalLoginPush");
            UpdateCode.EUpdateCodeMedalAdd = this.getCodeByName("EUpdateCodeMedalAdd");
            UpdateCode.EUpdateCodeLastHitBossDrop = this.getCodeByName("EUpdateCodeLastHitBossDrop");
            UpdateCode.EUpdateCodePeaceBossDrop = this.getCodeByName("EUpdateCodePeaceBossDrop");
            UpdateCode.EUpdateCodeGetTodayOnlineReward = this.getCodeByName("EUpdateCodeGetTodayOnlineReward");
            UpdateCode.EUpdateCodeFlopGift = this.getCodeByName("EUpdateCodeFlopGift");
            PetConst.TALENT_SKILL_START_POS = this.getValueByName("PetSkillPosRangeGift");
            PetConst.TALENT_SKILL_END_POS = this.getValueExByName("PetSkillPosRangeGift");
            PetConst.PASSIVE_SKILL_START_POS = this.getValueByName("PetSkillPosRange");
            PetConst.PASSIVE_SKILL_END_POS = this.getValueExByName("PetSkillPosRange");
            PetConst.OPEN_SKILL_POS_5_REQUIRE_GROWTH = this.getValueByName("PetSkillPos5");
            PetConst.OPEN_SKILL_POS_6_REQUIRE_GROWTH = this.getValueByName("PetSkillPos6");
            PetConst.OPEN_SKILL_POS_7_REQUIRE_GROWTH = this.getValueByName("PetSkillPos7");
            PetConst.OPEN_SKILL_POS_8_REQUIRE_GROWTH = this.getValueByName("PetSkillPos8");
            GameConst.MainCityFinalWinRewardsCode = this.getValueByName("TConstMainCityBattle2FirstGiftBagCode");
            GameConst.MainCityFinalLostRewardsCode = this.getValueByName("TConstMainCityBattle2SecondGiftBagCode");
            GameConst.MainCityKOLostRewardsCode = this.getValueByName("MainCityBattle1LoseGiftBagCode");
            GameConst.MainCityKOWinRewardsCode = this.getValueByName("MainCityBattle1WinGiftBagCode");
            return;
        }// end function

        public function getObjectByName(param1:String) : Object
        {
            return this._map[param1];
        }// end function

        public function getValueByName(param1:String) : int
        {
            var _loc_2:* = this._map[param1];
            if (_loc_2)
            {
                return _loc_2.constValue;
            }
            ThrowError.show("constConfig: " + param1 + " 不存在");
            return 0;
        }// end function

        public function getValueExByName(param1:String) : int
        {
            var _loc_2:* = this._map[param1];
            if (_loc_2)
            {
                return _loc_2.constValueEx;
            }
            ThrowError.show("constConfig: " + param1 + " 不存在");
            return 0;
        }// end function

        public function getCodeByName(param1:String) : int
        {
            var o:Object;
            var name:* = param1;
            try
            {
                o = this._updateMap[name];
                return o.updateCode;
            }
            catch (e:Error)
            {
                throw new Error("错误:" + name);
            }
            return 0;
        }// end function

        public function getOutUpdateStrByCode(param1:int) : String
        {
            var o:Object;
            var code:* = param1;
            try
            {
                o = this._updateCodeKeyMap[code];
                if (o.outUpdateStr)
                {
                    return o.outUpdateStr;
                }
                else
                {
                    return "";
                }
            }
            catch (e:Error)
            {
                return "";
            }
            return "";
        }// end function

        public static function get instance() : ConstConfig
        {
            if (_instance == null)
            {
                _instance = new ConstConfig;
            }
            return _instance;
        }// end function

    }
}
